package classloader;

public class MyTest10 {

    static {
        System.out.println("MyTest10 static block");
    }

    public static void main(String[] args) {
        Parent2 parent2;
        System.out.println("------------");
        parent2 = new Parent2();
        System.out.println("------------");
        System.out.println(Parent2.a);
        System.out.println("------------");
        System.out.println(Child2.b);
/*执行结果：由于父类已经初始化过了所以Parent2只输出一次
 MyTest10 static block
------------
Parent2 static block
------------
2
------------
Child2 static block
3
*/
    }
}

class Parent2 {
    static int a = 2;

    static {
        System.out.println("Parent2 static block");
    }
}

class Child2 extends Parent2 {
    static int b = 3;

    static {
        System.out.println("Child2 static block");
    }
}
